package cn.deschen.common.config.security;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author hanbin_chen
 * @Description jwt认证配置
 * @DateTime 2021/6/3
 * @Version V1.0.0
 */
@Configuration
@EnableConfigurationProperties(JwtProperties.class)
public class JwtAuthSecurityConfig {

    @Bean
    public FilterRegistrationBean requestBodyFilterRegistration(JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter){
        FilterRegistrationBean registration = new FilterRegistrationBean();
        //添加过滤器
        registration.setFilter(jwtAuthenticationTokenFilter);
        //设置过滤路径，/*所有路径
        registration.addUrlPatterns("/*");
        registration.setName("jwtAuthenticationTokenFilter");
        //设置优先级
        registration.setOrder(0);
        return registration;
    }
}
